<script setup>
   import axios from './utils/axios';

   import {ref , onMounted} from 'vue'

  //发送请求获取土味情话并且展示,切换按钮
   let message = ref("没有情话!!");

  //axios自动返回一个promise对象
  let getHttpData = async ()=>{
    let {data:{content}} = await axios.post("/api/rand.qinghua",{id:1},{params:{format:"json"}});
    //axios 会对结果进行二次封装  {data: 接口真正的结果 , status: 响应状态码}
    //console.log(code,content);
    message.value = content;
  }
   
  onMounted(()=>{
    getHttpData();
  });

</script>

<template>
  <div>
      {{message}} 
      <br>
      <button @click="getHttpData()">切换</button>
  </div>
</template>

<style scoped>

</style>